package org.speed.spring.core.aop;

import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;

public class ProxyFactoryDemo {

	public static void main(String[] args) {

		ProxyFactory proxyFactory = new ProxyFactory();
		proxyFactory.setTarget(new LoginServiceImpl());
		proxyFactory.setInterfaces(LoginService.class);
		
		
		DefaultPointcutAdvisor advisor1 = new DefaultPointcutAdvisor(new LoginBeforeAdvice());
		DefaultPointcutAdvisor advisor2 = new DefaultPointcutAdvisor(new LoginAfterAdvice());

		proxyFactory.addAdvisor(advisor1);
		proxyFactory.addAdvisor(advisor2);
		
		//proxyFactory.addAdvice(new LoginBeforeAdvice());
		//proxyFactory.addAdvice(new LoginAfterAdvice());
		
		LoginService proxy = (LoginService) proxyFactory.getProxy();
		proxy.login();

	}

}
